package com.xej.seat.tag;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.xej.seat.service.TagCacheService;
import com.xej.seat.util.DoubleUtil;
import com.xej.seat.vo.Customer;

@Service
public class LevelCustomerTag extends Tag {
	
	@Autowired
	private TagCacheService tagCacheService;
	
	//资产比例
	private final static String ASSET_PROPORTION = "ASSET_PROPORTION";
	//职级比例
	private final static String CUSLEVEL_PROPORTION = "CUSLEVEL_PROPORTION";
	//职级扩大比例
	private final static String CUSLEVEL_EXPAND = "CUSLEVEL_EXPAND";
	
	@Override
	public double getWeight(Object obj) {
		Customer cus = (Customer) obj;
		double levelCent = this.getTagWeight(CUSLEVEL_PROPORTION) - cus.getCusLevel() * this.getTagWeight(CUSLEVEL_EXPAND);
		double assetCent = DoubleUtil.mul(cus.getAssets(), DoubleUtil.div(this.getTagWeight(ASSET_PROPORTION), 9999999d, 10));
		return DoubleUtil.add(levelCent, assetCent);
		
	}
	
	private double getTagWeight(String tagName) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("name", tagName);
		List<com.xej.seat.vo.Tag> tags = this.tagCacheService.queryTagByParams(params);
		return tags.get(0).getWeight();
	}
	
	public static void main(String[] args) {
		//资产比例
	}
	
}
